package com.example.alarmclock;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.PowerManager;
import android.os.Vibrator;
import android.util.Log;

public class AlarmReceiver extends BroadcastReceiver {

    private static final String TAG = "AlarmReceiver";
    private static final String WAKE_LOCK_TAG = "com.example.alarmclock:wakelocktag";

    @Override
    public void onReceive(Context context, Intent intent) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, WAKE_LOCK_TAG);
        wl.acquire();

        try {
            Intent alarmIntent = new Intent(context, AlarmAlertActivity.class);
            alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            alarmIntent.putExtra("alarm_info", intent.getStringExtra("alarm_info"));
            context.startActivity(alarmIntent);
            Log.d(TAG, "Started AlarmAlertActivity.");
        } catch (Exception e) {
            Log.e(TAG, "Error starting AlarmAlertActivity: " + e.getMessage());
        }

        wl.release();
    }
}



